import os

folder_path = "bird_person_rec/data/labels/train"

# 获取所有带有"_flipped.txt"后缀的文件
flipped_files = [f for f in os.listdir(folder_path) if f.endswith("_flipped.txt")]

for file_name in flipped_files:
    file_path = os.path.join(folder_path, file_name)

    # 修改文件内容
    with open(file_path, "r") as f:
        lines = f.readlines()

    with open(file_path, "w") as f:
        for line in lines:
            line_split = line.split()
            if len(line_split) > 0:
                first_char = line_split[0][0]
                if first_char == "0":
                    line_split[0] = "1" + line_split[0][1:]
                elif first_char == "1":
                    line_split[0] = "0" + line_split[0][1:]
            new_line = " ".join(line_split) + "\n"
            f.write(new_line)
